package com.qf.service.impl;

import com.qf.mapper.GoodsMapper;
import com.qf.pojo.Goods;
import com.qf.pojo.GoodsCategory;
import com.qf.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public List<Goods> findAll() {
        return goodsMapper.selectByExample(null);
    }

    @Override
    public void deleteAll(Integer[] ids) {
        System.out.println("service deleteAll()" + Arrays.toString(ids));
        goodsMapper.deleteAll(ids);
    }

    @Override
    public void deleteById(Integer id) {
        goodsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void addGoods(Goods goods) {
        goodsMapper.insertSelective(goods);
    }

    @Override
    public void updateGoods(Goods goods) {
        goodsMapper.updateByPrimaryKeySelective(goods);
    }

    @Override
    public List<GoodsCategory> findGoodsCategory() {
        return goodsMapper.findGoodsCategory();
    }
}
